

<template>
  <div class="" :key="page_key" v-show="this.showHeader">
    <van-nav-bar
      class="header_title"
      :title="title"
      left-text=""
      left-arrow
      @click-left="onClickLeft"
    />
  </div>
</template>

<script>
export default {
  name: "headerVue",
  data() {
    return {
      title: "",
      page_key: 0,
    };
  },
  props: {
    showHeader: {
      type: Boolean,
      default: true,
    },
    header_title: {
      type: String,
      default: "",
    },
    back_url: {
      type: String,
      default: "/",
    },
  },
  created() {
    // this.getIndex();
    // this.$store.dispatch("saveForm", { bb: "cc" });
    if (this.header_title) {
      this.title = this.header_title;
    }
  },
  activated() {
    this.page_key++;
  },
  methods: {
    onClickLeft() {
      this.$router.push(this.back_url);
    },
    getIndex() {
      this.$axios
        .get("api/index/index")
        .then((res) => {})
        .catch((error) => {});
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="stylus" >
.header_title.van-nav-bar{
  background: none;
  position: fixed;
  z-index: 1000;
  width: 100%;

  &::after {
    content: none;
  }

  .van-nav-bar__left {
  }

  .van-nav-bar__text {
    color: white;
  }

  .van-icon-arrow-left::before {
    color: #fff;
    font-size: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 100%;
    height: 25px;
    width: 25px;
    line-height: 25px;
    text-align: center;
  }
}
</style>

